
function CancelOrder(orderNumber ) {
	//取消订单
	MuiAjaxFn("client/orderinfo/update", "{'orderNumber':'" + orderNumber + "','orderState':'Cancel_Order' , 'paymentState':'Unfinished'}", function(data) {
		
		if(data.dataResultObj.status == 200){
			mui.toast("取消订单成功!");
		}
	});
}


function CompleteOrder(orderNumber ) {
	//确认收货
	MuiAjaxFn("client/orderinfo/ordercomplete", "{'orderNumber':'" + orderNumber + "'}", function(data) {
		//确认收货
		if(data.dataResultObj.status == 200){
			mui.toast("确认收货成功!");
		}
	});
}

function seeOrder(orderNumber){
	//查看订单
	window.location.href="order_see.html?orderNumber="+orderNumber;
}

function RSubmitOrder(orderNumber) {
	//重新付款
	MuiAjaxFn("client/orderinfo/againneworder", "{'orderNumber':'" + orderNumber + "'}", function(data) {
		console.log(data.dataResultObj);
		if(typeof WeixinJSBridge == "undefined") {
			if(document.addEventListener) {
				document.addEventListener('WeixinJSBridgeReady', onBridgeReady, false);
			} else if(document.attachEvent) {
				document.attachEvent('WeixinJSBridgeReady', onBridgeReady);
				document.attachEvent('onWeixinJSBridgeReady', onBridgeReady);
			}
		} else {
			resetonBridgeReady(data);
		}
	})
}

function resetonBridgeReady(data) {
	//付款拉取窗口
	console.log(data);
	WeixinJSBridge.invoke(
		'getBrandWCPayRequest', {
			"appId": data.dataResultObj.appId, //公众号名称，由商户传入     
			"timeStamp": data.dataResultObj.timeStamp, //时间戳，自1970年以来的秒数     
			"nonceStr": data.dataResultObj.nonceStr, //随机串     
			"package": data.dataResultObj.prepayId,
			"signType": "MD5", //微信签名方式：     
			"paySign": data.dataResultObj.paySign //微信签名 
		},
		function(res) {
//			alert(JSON.stringify(res.err_msg));
			if(res.err_msg == "get_brand_wcpay_request:ok") {
				mui.toast("支付成功");
			} else if(res.err_msg == "get_brand_wcpay_request:cancel") {
				mui.toast("已取消支付");

			} else if(res.err_msg == "get_brand_wcpay_request:fail") {
				mui.toast("订单异常");
			} // 使用以上方式判断前端返回,微信团队郑重提示：res.err_msg将在用户支付成功后返回    ok，但并不保证它绝对可靠。
			window.location.reload()
		}

	);
}


function EvaluateOrder(orderNumber){
	window.location.href="evaluation.html?orderNumber="+orderNumber;
	
}
